--[[
CastYeller2 - Announce important spell events.

Copyright (C) 2009 Adirelle

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--]]

if not CastYeller2 then return end
local CastYeller2 = CastYeller2 
local L = CastYeller2.L

local mod, super = CastYeller2:NewSinkModule('Whisper')

mod.moduleTitle = L['Whisper']

local pName = UnitName('player')

function mod:Sink(announce, info)
	local target = info.target
	if target == pName then return end
	if UnitIsPlayer(target) and UnitCanCooperate("player", target) and not UnitCanAttack("player", target) then
		local oldTarget = info.target
		info.target = L['YOU']
		local message = self.core:FormatMessage(info.messageFormat, info)
		info.target = oldTarget
		if self.core.db.profile.squareBrackets then
			message = '<< '..message..' >>'
		end	
		SendChatMessage(message, 'WHISPER', nil, target)
	end
end

